layui.use(['form','layer','laydate','table','laytpl','element'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laypage = layui.laypage;
        element = layui.element;
        var page ;
    //新闻列表
    getPage();
    function getList(page) {
        var postData =  $.param({"limit":"10"}) + "&" + $.param({"page":page}) + "&" +$("#formDate").serialize() + "";
        var listUrl  =$('#ajaxList').val();
        $.ajax({
            type: "post",
            url: listUrl,
            data: postData,
            async:false,
            success: function(msg){
                $('#content').html(msg);
            }
        })
    };
    element.init();

    function getPage() {
        var postData =  $("#formDate").serialize();
        var pageUrl  =$('#ajaxPage').val();
        $.ajax({
            type: "post",
            url: pageUrl,
            data: postData,
            async:false,
            success: function(msg){
                $('#count').val(msg);
                page = msg;
            }
        });
        return page;
    }

    //执行一个laypage实例
    laypage.render({
        elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
        ,count: page //数据总数，从服务端得到
        ,limit:10
        , jump: function (obj, first) { //obj为当前页的属性和方法，第一次加载first为true
            getList(obj.curr);
        }
    });
    var info = $('#info').val();
    $('.addNews_btn').click(function () {
        layer.open({
            type: 2,
            title: '操作',
            shadeClose: true,
            shade: 0.8,
            area: ['700px','700px'],
            content: info //iframe的url
        });
    })

    $(".edit").on("click",function(){
        var menu_id=$(this).attr("lay-id");
        layer.open({
            type: 2,
            title: '操作',
            shadeClose: true,
            shade: 0.8,
            area: ['700px','700px'],
            content: info+'/menu_id/'+menu_id //iframe的url
        });
    });
})